<?php

require_once(OC_App::getAppPath('resumes') . "/lib/helper.php");
require_once(OC_App::getAppPath('company') . "/lib/subaccounts.php");
require_once(JPATH_SITE.'/components/com_city/helper.php');

if(!PFactory::isMasterUser()) {
   echo '您无权访问该资源';
   exit();
}

OCP\JSON::callCheck();

$companyid = PFactory::getMasterUser()->id;

$jobcity = JRequest::getString('jc', '');
$jobikey = JRequest::getString('ik', '');
$keyword = JRequest::getString('q', '');
$uid = JRequest::getString('uid', '');
$source = JRequest::getString('source', '');

$cityPageUrl = $ikeyPageUrl = OC_Helper::linkTo('company','ajax/getsubaccountsjoblist.php');

if (!empty($keyword)) {
   list($cityPageUrl, $selected) = PResumesHelper::getSearchItemHref($cityPageUrl, 'q', $keyword);
}
if (!empty($jobcity)) {
   list($cityPageUrl, $selected) = PResumesHelper::getSearchItemHref($cityPageUrl, 'jc', $jobcity);
}
if (!empty($jobikey)) {
   list($ikeyPageUrl, $selected) = PResumesHelper::getSearchItemHref($cityPageUrl, 'ik', $jobikey);
} else {
   list($ikeyPageUrl, $selected) = PResumesHelper::getSearchItemHref($cityPageUrl, 'ik', 'all');
}

$jobcitylist = PResumesHelper::getJobCityList($companyid);
$jobikeylist = PResumesHelper::getJobIkeyList($companyid);

$jobList = PResumesHelper::getJobList($companyid, 0, $keyword, $jobcity, $jobikey,$source);

$tmpl = new OCP\Template('company', 'part.subaccounts.joblist', '');
$tmpl->assign('cityPageUrl', $cityPageUrl);
$tmpl->assign('ikeyPageUrl', $ikeyPageUrl);
$tmpl->assign('jobcitylist', $jobcitylist);
$tmpl->assign('jobikeylist', $jobikeylist);
$tmpl->assign('source', $source);
$tmpl->assign('jobList', $jobList);
$tmpl->printPage();